package com.example.goodfood;

import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;

import android.R;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.util.Log;

public class ViewFromURL {

	public Bitmap GetImageFromURL(String strImageURL) 
	{    Bitmap imgBitmap = null;     
	try 
	{        
		URL url = new URL(strImageURL);
		URLConnection conn = url.openConnection();
		conn.connect();
		int nSize = conn.getContentLength();
		BufferedInputStream bis = new BufferedInputStream(conn.getInputStream(), nSize);
		imgBitmap = BitmapFactory.decodeStream(bis);
		bis.close();    } 
		catch (Exception e) 
		{
			Log.i("TAG","error from BitmapFactory " +  e.getMessage());
			imgBitmap = BitmapFactory.decodeResource(Resources.getSystem(), R.drawable.alert_light_frame);
			return imgBitmap;
		}
		return imgBitmap;
	}
	

}
